package com.meichis.yndms.repository.manager;

import com.google.gson.reflect.TypeToken;
import com.meichis.yndms.http.CallSubscriber;
import com.meichis.yndms.http.IWebServiceCallback;
import com.meichis.yndms.http.RetrofitUtil.RxSchedulersHelper;
import com.meichis.yndms.model.DSPToken;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-06-05 19:11
 */
public class HeartBeatManager extends BaseManager {

    private static HeartBeatManager INSTANCE;

    public static HeartBeatManager getInstance() {
        if (INSTANCE == null) {
            synchronized (HeartBeatManager.class) {
                if (INSTANCE == null) {
                    INSTANCE = new HeartBeatManager();
                }
            }
        }
        return INSTANCE;
    }

    public void refreshToken( String refresh_token, IWebServiceCallback callback) {
        getRootApi().refreshToken("refresh_token", refresh_token, "app", "app").compose(RxSchedulersHelper.rxSchedulerHelper()).subscribe(new CallSubscriber(new TypeToken<DSPToken>() {
        }.getType(), callback));
    }
}
